#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
wsite 配置文件
script name: config
Created on 2020/2/15 17:17 by PyCharm
@author: fujianjian
"""
import os

basedir = os.path.abspath(os.path.dirname(__file__))
# print('config.py basedir', basedir)


class Config:
    """
    配置基类
    """
    SECRET_KEY = 'WSite_OpsMgr2007R2'

    # mail module config
    MAIL_SERVER = os.environ.get('MAIL_SERVER', 'smtp.sina.cn')
    MAIL_PORT = int(os.environ.get('MAIL_PORT', '25'))
    MAIL_USE_TLS = os.environ.get('MAIL_USE_TLS', 'true').lower() in ['true', 'on', '1']
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    MAIL_SUBJECT_PREFIX = '[WSite]'
    MAIL_SENDER = 'WSite Admin<{}>'.format(MAIL_USERNAME)

    # db module config
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    @staticmethod
    def init_app():
        pass


class DevConfig(Config):
    DEBUG = True

    SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URI') \
                              or 'sqlite:///' + os.path.join(basedir, 'wsite_dev.sqlite')
    pass


class TestConfig(Config):
    TESTING = True

    SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URI') \
                              or 'sqlite:///' + os.path.join(basedir, 'wsite_test.sqlite')
    pass


class ProdConfig(Config):
    SQLALCHEMY_DATABASE_URI = os.environ.get('PROD_DATABASE_URI') \
                              or 'sqlite:///' + os.path.join(basedir, 'wsite.sqlite')
    pass


config = {
    'dev': DevConfig,
    'test': TestConfig,
    'prod': ProdConfig,
    'default': DevConfig
}
